package com.djl.zenithbite.controller.shopping.order;


import com.djl.zenithbite.common.response.BaseResponse;
import com.djl.zenithbite.config.annotation.UserAuthAnnotation;
import com.djl.zenithbite.dto.request.shopping.order.AddOrderRequest;
import com.djl.zenithbite.dto.request.shopping.order.DeleteOrderRequest;
import com.djl.zenithbite.dto.response.order.OrderDetailResponse;
import com.djl.zenithbite.service.shopping.order.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    @UserAuthAnnotation
    @PostMapping("/add")
    public BaseResponse<Integer> addOrder(@RequestBody AddOrderRequest request){
        return orderService.addOrder(request);
    }

    @UserAuthAnnotation
    @GetMapping("/list")
    public BaseResponse<List<OrderDetailResponse>> listOrder(){
        return orderService.listOrder();
    }

    @UserAuthAnnotation
    @PostMapping("/delete")
    public BaseResponse<Void> deleteOrder(@RequestBody DeleteOrderRequest request){
        return orderService.deleteOrder(request.getOrderId());
    }
}
